<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Book Review</title>
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/meniu.css" />
	<link rel="stylesheet" type="text/css" href="css/style.css" />
</h:head>

<h:body>

	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">
		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contentRight">
			<f:event type="preRenderView"
				listener="#{bookTableData.preRenderView}" />

			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>Submit review for book with title "<h:outputText
								value="#{bookTableData.bookToBeReviewed.name}" />" by <h:outputText
								value="#{bookTableData.bookToBeReviewed.author}" />, year <h:outputText
								value="#{bookTableData.bookToBeReviewed.year}" /></a></li>
				</ul>
			</h:panelGroup>

			<h:panelGroup layout="block"
				rendered="#{reviewBean.errorMessage != null}">
				<h:panelGrid columns="1">
					<h:outputText value="#{reviewBean.errorMessage}" />
				</h:panelGrid>
			</h:panelGroup>

			<h:panelGroup layout="block" styleClass="contentLeft">
				<h:form id="reviewForm" enctype="multipart/form-data">
					<h:panelGrid id="pg1" columns="2">
						<h:commandButton id="backButton" style="width:50px; height:30px;"
							image="resources/img/back-button.png" action="bookCRUD.xhtml"
							immediate="true" />
						<br></br>
						<h:outputText
							rendered="#{bookTableData.containsCristicsReview(bookTableData.bookToBeReviewed.id)}"
							style="color:red"
							value="A critic's review for this book was already submitted. By submitting another review, the old one will be overriden." />
					</h:panelGrid>
				</h:form>
				<h:form id="reviewForm2" enctype="multipart/form-data">
					<h:panelGrid id="pg2" columns="2">
						<p:fileUpload fileUploadListener="#{reviewBean.handleFileUpload}"
							mode="advanced" dragDropSupport="false" update="@all"
							fileLimit="1" allowTypes="/(\.|\/)(pdf)$/" label="Browse"
							sizeLimit="10485760" cancelLabel="Remove File">
							<f:attribute name="bookId"
								value="#{bookTableData.bookToBeReviewed.id}" />
						</p:fileUpload>
						<p:growl id="messages" showDetail="true" />
					</h:panelGrid>
				</h:form>
			</h:panelGroup>

		</h:panelGroup>
	</h:panelGroup>
</h:body>
</html>